Skip to content

IntListValidator

Base classes

Name Children Inherits
BaseRegexValidator
prettyqt.validators.regexvalidators

⋔ Inheritance diagram

graph TD
  1340355666["validators.IntListValidator"]
  1591271330["validators.BaseRegexValidator"]
  422589614["gui.Validator"]
  1804432572["gui.ValidatorMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  49520861["QtGui.QValidator"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  1591271330 --> 1340355666
  422589614 --> 1591271330
  1804432572 --> 422589614
  3227531497 --> 1804432572
  2751680898 --> 3227531497
  49520861 --> 422589614
  3984060476 --> 49520861
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 DocStrings

Bases: BaseRegexValidator

Validator which checks whether given string is a comma-separated list of ints.

Source code in prettyqt/validators/regexvalidators.py
class IntListValidator(BaseRegexValidator):
    """Validator which checks whether given string is a comma-separated list of ints."""

    ID = "int_list"

    def __init__(self, allow_single: bool = True, parent: QtCore.QObject | None = None):
        super().__init__(parent=parent)
        self.allow_single = allow_single
        if allow_single:
            self.set_regex(r"^(\d+)(,\s*\d+)*$")
        else:
            self.set_regex(r"^[0-9][0-9\,]+[0-9]$")

    def __reduce__(self):
        return type(self), (self.allow_single,)

    def __repr__(self):
        return get_repr(self, allow_single=self.allow_single)

:fa-brands-github: Show source on GitHub